package com.xkdx.guangguang.fragment.user;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.xkdx.guangguang.module.network.AbsAction;
import com.xkdx.guangguang.module.statics.IConstants;

public class UserUpdateBaseInfoAction extends AbsAction {

	String userID, updateInfo, loginToken;
	int index;

	public UserUpdateBaseInfoAction(String userID, String updateInfo,
			String loginToken, int index) {
		url = IConstants.addressV2;
		this.userID = userID;
		this.updateInfo = updateInfo;
		this.loginToken = loginToken;
		this.index = index;
	}

	@Override
	public void constructRequest() {
		List<Parameter> list = new ArrayList<Parameter>();
		if (index == 1) {
			HashMap<String, String> sexmap = new HashMap<String, String>();
			sexmap.put("UserID", userID);
			sexmap.put("Sex", updateInfo);
			sexmap.put("LoginToken", loginToken);

			String sexJson = constructJson(sexmap);
			Parameter parameter = new Parameter("userInterface", "editUserSex",
					sexJson);
			list.add(parameter);
		} else if (index == 2) {
			HashMap<String, String> birthdaymap = new HashMap<String, String>();

			birthdaymap.put("UserID", userID);
			birthdaymap.put("Birthday", updateInfo);
			birthdaymap.put("LoginToken", loginToken);

			String birthdayJson = constructJson(birthdaymap);
			Parameter parameter1 = new Parameter("userInterface",
					"editUserBirthday", birthdayJson);
			 list.add(parameter1);
			
		} else if (index == 3) {
			HashMap<String, String> emailmap = new HashMap<String, String>();

			emailmap.put("UserID", userID);
			emailmap.put("Email", updateInfo);
			emailmap.put("LoginToken", loginToken);

			String emailJson = constructJson(emailmap);
			Parameter parameter2 = new Parameter("userInterface",
					"editUserEmail", emailJson);
			 list.add(parameter2);
		} else {
			HashMap<String, String> phonemap = new HashMap<String, String>();

			phonemap.put("UserID", userID);
			phonemap.put("MobilePhone", updateInfo);
			phonemap.put("LoginToken", loginToken);

			String phoneJson = constructJson(phonemap);
			Parameter parameter3 = new Parameter("userInterface",
					"editUserMobilePhone", phoneJson);
			 list.add(parameter3);
		}
		requestData = constructMod(list);
	}
}
